<?php require_once '../util/verifyMenu.php';?>
<?php require_once '../util/verifyLogin.php';?>
<?php require_once '../util/header.php';?>
<body>
<div class="mycontent" align="center">
<img src="public/img/header.png" style="width: 1024px; margin: -6px;">
<?php require_once '../util/menu.php';?>
<div align="left">
&nbsp;&nbsp;&nbsp;ยอดซื้อ <b><?php echo $_SESSION['profit'];?></b> บาท&nbsp;&nbsp;&nbsp;
<input type="button" class="btn btn-info" value="ดูประวัติการซื้อ" style="margin-right: 20px;" onclick="javascript:location.href='../control/buydetailControl.php'">
<span style="float: right;">
สวัสดี คุณ <b><?php echo $_SESSION['name']." ".$_SESSION['lastname'];?></b>&nbsp;&nbsp;&nbsp;
<input type="button" class="btn" value="ออกจากระบบ" style="margin-right: 20px;" onclick="javascript:location.href='../util/logout.php'">
</span>
</div>
<h2>Choose Seat</h2>
<hr>
<form name="frm" action="../control/_lendControl.php" method="post">
<b>การเดินทาง : <?php echo $_SESSION['route'];?> </b><br>
<b>เวลารถออก : <?php echo $_SESSION['xtime'];?> </b><br>
<b>เวลารถถึง : <?php echo $_SESSION['ytime'];?> </b><br>
<b>ประเภท : <?php echo $_SESSION['type'];?> </b><br>
<b>ราคา / หน่วย : <?php echo $_SESSION['price'];?> </b>
<?php 
$num = array("ป.1" => 40,"ป.2" => 60,"Vip" => 24);
	$idx = 1;
	echo "<h3>ด้านหน้า</h3><table>";
	$_SESSION['num'] = $num[$_SESSION['type']]/4;
	for ($i = 0; $i < $num[$_SESSION['type']]/4; $i++) {
		$nameA = "a".($idx);
		$nameB = "b".($idx);
		$nameC = "c".($idx);
		$nameD = "d".($idx);
		echo "<tr>";
		echo isDup($nameA);
		echo isDup($nameB);
		echo "<td class='seat'></td>";
		echo isDup($nameC);
		echo isDup($nameD);
		echo "</tr>";
		$idx++;
	echo "<table>";
}
function isDup($str){
	for ($i = 0; $i < count($_SESSION['seat']); $i++) {
		if($_SESSION['seat'][$i] == $str){
			return "<td class='seat-dup'><input type='checkbox' name='$str' value='$str' disabled> $str</td>";
		}
	}
	return "<td class='seat'><input type='checkbox' name='$str' value='$str'> $str</td>";
}
?>
<br><br>
<input type="submit" class="btn btn-large btn-primary" value="ต่อไป">
</form>
<?php require_once '../util/footer.php';?>

</div>
</body>
